Full source code website bán hàng thương mại điện tử gần giống shopee
472.070 lượt xem;
1 $(document).ready(function() {
2
3 var animating = false,
4 submitPhase1 = 1100,
5 submitPhase2 = 400,
6 logoutPhase1 = 800,
7 $login = $(".login"),
8 $app = $(".app");
9
10 function ripple(elem, e) {
11 $(".ripple").remove();
12 var elTop = elem.offset().top,
13 elLeft = elem.offset().left,
14 x = e.pageX - elLeft,
15 y = e.pageY - elTop;
16 var $ripple = $("<div class='ripple'></div>");
17 $ripple.css({top: y, left: x});
18 elem.append($ripple);
19 };
20
21 $(document).on("click", ".login__submit", function(e) {
22 if (animating) return;
23 animating = true;
24 var that = this;
25 ripple($(that), e);
26 $(that).addClass("processing");
27 setTimeout(function() {
28 $(that).addClass("success");
29 setTimeout(function() {
30 $app.show();
31 $app.css("top");
32 $app.addClass("active");
33 }, submitPhase2 - 70);
34 setTimeout(function() {
35 $login.hide();
36 $login.addClass("inactive");
37 animating = false;
38 $(that).removeClass("success processing");
39 }, submitPhase2);
40 }, submitPhase1);
41 });
42
43 $(document).on("click", ".app__logout", function(e) {
44 if (animating) return;
45 $(".ripple").remove();
46 animating = true;
47 var that = this;
48 $(that).addClass("clicked");
49 setTimeout(function() {
50 $app.removeClass("active");
51 $login.show();
52 $login.css("top");
53 $login.removeClass("inactive");
54 }, logoutPhase1 - 120);
55 setTimeout(function() {
56 $app.hide();
57 animating = false;
58 $(that).removeClass("clicked");
59 }, logoutPhase1);
60 });
61
62 });
2
3 var animating = false,
4 submitPhase1 = 1100,
5 submitPhase2 = 400,
6 logoutPhase1 = 800,
7 $login = $(".login"),
8 $app = $(".app");
9
10 function ripple(elem, e) {
11 $(".ripple").remove();
12 var elTop = elem.offset().top,
13 elLeft = elem.offset().left,
14 x = e.pageX - elLeft,
15 y = e.pageY - elTop;
16 var $ripple = $("<div class='ripple'></div>");
17 $ripple.css({top: y, left: x});
18 elem.append($ripple);
19 };
20
21 $(document).on("click", ".login__submit", function(e) {
22 if (animating) return;
23 animating = true;
24 var that = this;
25 ripple($(that), e);
26 $(that).addClass("processing");
27 setTimeout(function() {
28 $(that).addClass("success");
29 setTimeout(function() {
30 $app.show();
31 $app.css("top");
32 $app.addClass("active");
33 }, submitPhase2 - 70);
34 setTimeout(function() {
35 $login.hide();
36 $login.addClass("inactive");
37 animating = false;
38 $(that).removeClass("success processing");
39 }, submitPhase2);
40 }, submitPhase1);
41 });
42
43 $(document).on("click", ".app__logout", function(e) {
44 if (animating) return;
45 $(".ripple").remove();
46 animating = true;
47 var that = this;
48 $(that).addClass("clicked");
49 setTimeout(function() {
50 $app.removeClass("active");
51 $login.show();
52 $login.css("top");
53 $login.removeClass("inactive");
54 }, logoutPhase1 - 120);
55 setTimeout(function() {
56 $app.hide();
57 animating = false;
58 $(that).removeClass("clicked");
59 }, logoutPhase1);
60 });
61
62 });